import java.util.Scanner;

/**
 * Creat with IntelliJ IDEA
 * Description:
 * User:WZW
 * Date:2022-04-23
 * Time:12:42
 */
public class Demo16 {
    private static volatile int isQuit = 0;//在变量之前加上volatile

    public static void main(String[] args) {
        Thread t = new Thread(()->{
            while (isQuit == 0){
                //用户输入之前，线程始终执行循环
            }
            System.out.println("循环结束！t线程退出");
        });
        t.start();

        Scanner scanner = new Scanner(System.in);
        System.out.println("请插入一个 isQuit 的值：");
        isQuit = scanner.nextInt();
        System.out.println("main 线程执行完毕！");
    }
}
